﻿{% extends "personal_center/base.html" %}

{% block page_link %}
    <link rel="stylesheet" href="../../static/technological/css/style.css">
    <link rel="stylesheet" href="../../static/public_file/css/PersonnelChooser.css">
{% endblock %}


{% block style %}
    <style>
        .add_class {
            background: #1E90FF;
        }

        .add_background {
            background: #A9A9A9;
        }

        .input-style {
            display: inline-block;
            width: 100%;
            height: 35px;
            font-size: 14px;
            border: none;
            background: white;
        }

        tr {
            height: 35px;
        }
        td {
            padding-right: 5px;outline: none;height: 40px;
        }
        th {
            text-align: center;
        }

        .file {
            position: relative;
            display: inline-block;
            background: #D0EEFF;
            border: 1px solid #99D3F5;
            border-radius: 4px;
            padding: 4px 12px;
            overflow: hidden;
            color: #1E88C7;
            text-decoration: none;
            text-indent: 0;
            line-height: 20px;
        }

        .file input {
            position: absolute;
            font-size: 100px;
            right: 0;
            top: 0;
            opacity: 0;
        }

        .file:hover {
            background: #AADFFD;
            border-color: #78C3F3;
            color: #004974;
            text-decoration: none;
        }

        .shade {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(36, 36, 36, 0.5);
            display: none;
            z-index: 10000;
        }

        #ThreeNavigation div {
            padding-left: 2%;
        }
    </style>
{% endblock %}


{% block right_content %}
    <div class="headline">
        <div style="width: 15%;height: 100%;line-height: 40px;float: left;padding-left: 1%;">
            <a href="#" style="color: #0b0b0b;">
                <i class="iconfont icon-faqi"></i>
                <a href="MiddleLevelCadres.html" style="color: #0b0b0b;">中层干部外出</a>
            </a>
        </div>
        <div style="height: 100%;line-height: 40px;float: right;text-align: right;padding-right: 15px;">
            <button id="add_station" type="button"
                    style="width: 100px;height: 30px;margin-top: 5px;border-radius: 3px;border: #1E90FF solid 1px;background-color: #1E90FF;color: white;line-height: 25px;"
                    onclick="save_data()">
                保存
            </button>
        </div>

        <div style="width: 15%;height: 100%;line-height: 40px;float: right;text-align: right;padding-right: 15px;">
            <button id="add_station" type="button"
                    style="width: 100px;height: 30px;margin-top: 5px;border-radius: 3px;border: #1E90FF solid 1px;background-color: #1E90FF;color: white;line-height: 25px;"
                    onclick="submit_data()">
                提交
            </button>
        </div>
    </div>
    <hr>

    <div style="width: 100%;height: 95%;overflow: auto;">
        <div id="menu_from"
             style="width: 100%;height: 100%;color: #2C3E50;display: inline-block;vertical-align: top;background: white;">
            <div style="width: 100%;height: 90%;display: inline-block;vertical-align: center;">
                <div style="width: 95%;margin-left: 2.5%;margin-top: 20px;">
                    <table style="width: 100%;">
                        <tr style="margin-left: 1%;">
                            <td colspan="4" style="width: 95%;margin-left: 2.5%;margin-top: 1%;height: 40px;padding-left: 0.5%;line-height: 40px;background: white;border: #cfcfcf solid 1px;text-align: center;">
                                <h3 id="form_name" style="letter-spacing: 8px;">京山市人民医院中层干部外出呈批表</h3>
                            </td>
                        </tr>
                        <tr style="margin-left: 1%;">
                            <td colspan="4" style="width: 95%;margin-left: 2.5%;height: 40px;padding-left: 0.5%;line-height: 40px;background: #dfdfdf;border: #cfcfcf solid 1px;border-top: none;">
                                基本信息
                            </td>
                        </tr>
                        <tr style="margin-left: 1%;">
                            <td style="width: 15%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;">
                                申&nbsp;&nbsp;请&nbsp;人
                            </td>
                            <td id="applicat"
                                style="width: 35%;height: 35px;line-height: 35px;padding-left: 1%;border: #cfcfcf solid 0.5px;">{{ realname }}</td>

                            <td style="width: 15%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;">
                                申请部门
                            </td>
                            <td id="department" style="width: 35%;border: #cfcfcf solid 0.5px;padding-left: 1%;line-height: 35px;">{{ department }}</td>
                        </tr>
                    </table>
                </div>

                <div style="width: 95%;margin-left: 2.5%;height: 40px;padding-left: 0.5%;line-height: 40px;background: #dfdfdf;">
                    申请详情
                </div>

                <div style="width: 95%;margin-left: 2.5%;;">
                    <table style="width: 100%;">
                        <tr style="margin-left: 1%;">
                            <td style="width: 15%;border-right: #cfcfcf solid 0.5px;border-left: #cfcfcf solid 0.5px;border-bottom: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;text-align: right;">
                                外出人员
                            </td>
                            <td id="outgoingpersonnel" style="width: 35%;border-right: #cfcfcf solid 0.5px;border-left: #cfcfcf solid 0.5px;border-bottom: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;padding-left: 1%;" onclick="model_line()">
                            </td>
                            <td style="width: 15%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;">
                                职&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;务
                            </td>
                            <td id="post" style="width: 35%;border: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;padding-left: 1%;outline: none;" contenteditable="true"></td>
                        </tr>
                        <tr style="margin-left: 1%;">
                            <td style="width: 15%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;border-top: none;">
                                开始时间
                            </td>
                            <td id="start_time" style="width: 35%;border: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;padding-left: 1%;border-top: none;"></td>
                            <td style="width: 15%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;border-top: none;">
                                结束时间
                            </td>
                            <td id="end_time" style="width: 35%;border: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;padding-left: 1%;border-top: none;"></td>
                        </tr>
                        <tr style="margin-left: 1%;">
                            {% if PartyGovOffice == 'true' %}
                                <td style="width: 15%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;border-top: none;">
                                    前往地点
                                </td>
                                <td id="destination" style="width: 35%;border: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;padding-left: 1%;border-top: none;" contenteditable="true"></td>
                                <td style="width: 15%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;border-top: none;">
                                    分管部门
                                </td>
                                <td id="department_charge" style="width: 35%;border: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;padding-left: 1%;border-top: none;">
                                    <input type="checkbox" class="department" onclick="SingleChoice(this)" value="3" {% if is_functional == 'false' %} disabled {% endif %}> 党委办公室&nbsp;&nbsp;&nbsp;&nbsp;
                                    <input type="checkbox" class="department" onclick="SingleChoice(this)" value="13"> 医务科&nbsp;&nbsp;&nbsp;&nbsp;
                                    <input type="checkbox" class="department" onclick="SingleChoice(this)" value="14"> 科教科&nbsp;&nbsp;&nbsp;&nbsp;
                                    <input type="checkbox" class="department" onclick="SingleChoice(this)" value="15"> 护理部&nbsp;&nbsp;&nbsp;&nbsp;
                                </td>
                            {% else %}
                                <td style="width: 15%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;border-top: none;">
                                    前往地点
                                </td>
                                <td id="destination" colspan="3" style="width: 85%;border: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;padding-left: 1%;border-top: none;" contenteditable="true"></td>
                            {% endif %}


                        </tr>
                        <tr style="margin-left: 1%;">
                            <td style="width: 15%;border: #cfcfcf solid 0.5px;text-align: right;height: 35px;line-height: 35px;border-top: none;">
                                外出事由
                            </td>
                            <td id="reasons" colspan="3" style="width: 85%;border: #cfcfcf solid 0.5px;height: 35px;line-height: 35px;padding-left: 1%;border-top: none;" contenteditable="true"></td>
                        </tr>
                    </table>
                </div>

                <div style="width: 95%;margin-left: 2.5%;">
                    <div style="width: 100%;height: 40px;line-height: 40px;background-color: #dfdfdf;color: #1E90FF;padding-left: 1%;border: #cccccc solid 1px;border-top: none;border-bottom: none;padding-right: 1%;">
                        上传附件
                        <a href="javascript:;" class="file" style="vertical-align: top;margin-top: 5px;float: right;">
                            上传文件
                            <input type="file" name="party_main_body" id="party_main_body"
                                   onchange="upload_accessory('file1', 'party_main', 'party_main_body')">
                        </a>
                    </div>
                    <table style="width: 100%;">
                        <thead>
                        <tr>
                            <td style="width: 5%;border: #cccccc solid 1px;text-align: center;">序号</td>
                            <td style="width: 20%;border: #cccccc solid 1px;border-left: none;text-align: center;">
                                文件名称
                            </td>
                            <td style="width: 20%;border: #cccccc solid 1px;border-left: none;text-align: center;">
                                文件大小
                            </td>
                            <td style="width: 20%;border: #cccccc solid 1px;border-left: none;text-align: center;">
                                上传时间
                            </td>
                            <td style="width: 20%;border: #cccccc solid 1px;border-left: none;text-align: center;">
                                上传人员
                            </td>
                            <td style="width: 15%;border: #cccccc solid 1px;border-left: none;text-align: center;">操作
                            </td>
                        </tr>
                        </thead>
                        <tbody style="overflow: auto;" id="party_main"></tbody>
                    </table>
                    <table style="width: 100%;">
                        <tr>
                            <td colspan="6" style="width: 100%;border: #cccccc solid 1px;border-top: none;color: red;padding-left: 0.5%;">
                                外出人员备注：<br>
                                所选出行人员分管领导必须为同一人！
                            </td>
                        </tr>
                        <tr>
                            <td colspan="6" style="width: 100%;border: #cccccc solid 1px;border-top: none;color: red;padding-left: 0.5%;">
                                分管部门报备备注：<br>
                                学术会议报备 科教科；<br>医疗会议报备 医务科；<br>护士长报备 护理部；<br>职能科室报备 党委办公室；
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <div id="staff-select" class="shade">
        <div id="staff-model" style="width: 100%;height: 100%;position: absolute;">
            <div style="width: 900px;height: 500px;background: #F5F5F5;z-index: 10000;position: absolute;top: 50%;left: 50%;transform:translate(-50%,-50%);border-radius: 3px;border: #dfdfdf solid 1px;">
                <div id="staff-box" style="width: 100%;height: 40px;background: #f4f7fa;cursor: move;border-top-left-radius: 5px;border-top-right-radius: 5px;border-bottom: #dfdfdf solid 1px;">
                    <div style="width: 20%;margin-left: 1%;display: inline-block;line-height: 40px;font-size: 14px;">
                        选择人员
                    </div>
                    <span onclick="close_model()" style="float: right;padding-right: 2%;cursor: pointer;line-height: 37px;">
                        <i class="iconfont icon-quchu"></i>
                    </span>
                </div>
                <div style="height: 460px;width: 100%;border-bottom: #dfdfdf solid 1px;">
                    <div style="width: 70px;height: 100%;border-right: #cfcfcf solid 1px;display: inline-block;vertical-align: top;">
                        <div id="dep" class="navigation navigation_color" onclick="change_navigation(this)">部门</div>
                        <div id="limits" class="navigation" onclick="change_navigation(this)">权限</div>
                        <div id="fun" class="navigation" onclick="change_navigation(this)">职能</div>
                    </div>
                    <div style="width: 200px;height: 100%;border-right: #cfcfcf solid 1px;display: inline-block;vertical-align: top;">
                        <div style="width: 100%;height: 50px;line-height: 50px;">
                            <input id="SearchDep" onkeydown="SearchDepartment()" class="search_input" type="text" placeholder="搜索" autocomplete="off" style="width: 95%;">
                        </div>
                        <div id="SecondaryNavigation" style="width: 100%;height: 403px;line-height: 50px;overflow: auto;"></div>
                    </div>
                    <div style="width: 200px;height: 100%;border-right: #cfcfcf solid 1px;display: inline-block;vertical-align: top;">
                        <div style="width: 100%;height: 50px;line-height: 50px;padding-left: 2%;">
                            <input type="checkbox" id="select-all" onclick="SelectAll(this)">
                            <input id="SearchPeo" onkeydown="SearchProple()" class="search_input" type="text" placeholder="搜索" autocomplete="off" style="width: 87%;">
                        </div>
                        <div id="ThreeNavigation" style="width: 100%;height: 403px;line-height: 50px;overflow: auto;"></div>
                    </div>
                    <div style="width: 410px;height: 100%;display: inline-block;vertical-align: top;overflow: auto">
                        <div style="width: 100%;height: 40px;text-align: left;font-size: 14px;line-height: 40px;">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;已选 <span id="selected-number">0</span> 人
                        </div>
                        <div id="selected-div" style="width: 100%;font-size: 14px;height: 370px;overflow: auto;line-height: 20px;">

                        </div>
                        <div style="width: 100%;font-size: 14px;height: 40px;text-align: center;">
                            <button onclick="IdentifyPersonnel()" style="width: 100px;height: 30px;line-height: 25px;text-align: center;letter-spacing: 5px;border-radius: 3px;border: #cfcfcf solid 1px;font-size: 14px;cursor: pointer;margin-top: 10px;">完成</button>
                            <button onclick="close_model()" style="margin-left: 15px;width: 100px;height: 30px;line-height: 25px;text-align: center;color: #0abb78;letter-spacing: 5px;border-radius: 3px;font-size: 14px;border: #cfcfcf solid 1px;cursor: pointer;margin-top: 10px;">取消</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}

{% block script %}
    <script type="text/javascript" src="../../static/public_file/other/jquery.js"></script>
    <script src="../../static/administrative/layDate-v5.0.9/laydate/laydate.js"></script> <!-- 改成你的路径 -->
    <script src="../../static/public_file/js/PersonnelChoosersNew.js" type="text/javascript" charset="gb2312"></script>
    <script type="text/javascript">
        window.onload = function () {
            document.getElementById("sponsor").className = "add_class";
            document.getElementById("personage").className = "add-nav-active";
        };
        lay('#version').html('-v' + laydate.v);

        //执行一个laydate实例
        laydate.render({
            elem: '#start_time', //指定元素
            type: 'date',
            format: 'yyyy-MM-dd'
        });
        laydate.render({
            elem: '#end_time', //指定元素
            type: 'date',
            format: 'yyyy-MM-dd'
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#date' //指定元素
        });
        const uuid = '{{ uuid }}'

        // 上传附件
        function upload_accessory(file_type, tbody_id, accessory_type) {
            document.getElementById("loading").style.display = "inline-block";
            var form = new FormData();
            var files = document.getElementById(accessory_type).files[0];
            form.append(file_type, files);
            form.append('number', uuid)
            form.append('source', 'yykcf')
            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/administrative/topics_attachments_upload", true);
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        console.log(JsonDate);
                        creat_table(JsonDate, tbody_id)
                    }
                }
            };
        }

        // 创建附件列表
        function creat_table(JsonData, tbody_id) {
            var t_table = document.getElementById(tbody_id);
            var local_host = window.location.host;
            if (Array.isArray(JsonData["pdf_path"])) {
                for (var i = 0; i < JsonData["pdf_path"].length; i++) {
                    var tr = document.createElement("tr");var td1 = document.createElement("td");var td2 = document.createElement("td");var td3 = document.createElement("td");var td4 = document.createElement("td");var td5 = document.createElement("td");var td6 = document.createElement("td");
                    td1.innerHTML = t_table.children.length + 1;td1.style.textAlign = "center";td1.style.border = "#cccccc solid 1px";td1.style.borderTop = "none";
                    td2.innerHTML = JsonData["file_name"];td2.style.paddingLeft = "1%";td2.style.border = "#cccccc solid 1px";td2.style.borderLeft = "none";td2.style.borderTop = "none";
                    td3.innerHTML = JsonData["file_size"];td3.style.textAlign = "center";td3.style.border = "#cccccc solid 1px";td3.style.borderLeft = "none";td3.style.borderTop = "none";
                    td4.innerHTML = JsonData["upload_time"];td4.style.textAlign = "center";td4.style.border = "#cccccc solid 1px";td4.style.borderLeft = "none";td4.style.borderTop = "none";
                    td5.innerHTML = JsonData["uploader"];td5.style.textAlign = "center";td5.style.border = "#cccccc solid 1px";td5.style.borderLeft = "none";td5.style.borderTop = "none";
                    td6.innerHTML = "<a target='_blank' href='" + JsonData["pdf_path"][i]["pdf_path"] + "'>查看</a> | <a style='color: red;' href='#' onclick='RemoveTr(this, \"" + tbody_id + "\", \"" + JsonData["pdf_path"][i]["id"] + "\")'>删除</a>";
                    td6.style.textAlign = "center";td6.style.border = "#cccccc solid 1px";td6.style.borderLeft = "none";td6.style.borderTop = "none";
                    tr.appendChild(td1);tr.appendChild(td2);tr.appendChild(td3);tr.appendChild(td4);tr.appendChild(td5);tr.appendChild(td6);
                    t_table.appendChild(tr);
                }
                if (JsonData["pdf_path"].length > 1) {
                    document.getElementById("del_adjunct").style.display = 'block';
                }
            } else {
                tr = document.createElement("tr");td1 = document.createElement("td");td2 = document.createElement("td");td3 = document.createElement("td");td4 = document.createElement("td");td5 = document.createElement("td");td6 = document.createElement("td");
                td1.innerHTML = t_table.children.length + 1;td1.style.textAlign = "center";td1.style.border = "#cccccc solid 1px";td1.style.borderTop = "none";
                td2.innerHTML = JsonData["file_name"];td2.style.paddingLeft = "1%";td2.style.border = "#cccccc solid 1px";td2.style.borderLeft = "none";td2.style.borderTop = "none";
                td3.innerHTML = JsonData["file_size"];td3.style.textAlign = "center";td3.style.border = "#cccccc solid 1px";td3.style.borderLeft = "none";td3.style.borderTop = "none";
                td4.innerHTML = JsonData["upload_time"];td4.style.textAlign = "center";td4.style.border = "#cccccc solid 1px";td4.style.borderLeft = "none";td4.style.borderTop = "none";
                td5.innerHTML = JsonData["uploader"];td5.style.textAlign = "center";td5.style.border = "#cccccc solid 1px";td5.style.borderLeft = "none";td5.style.borderTop = "none";
                td6.innerHTML = "<a target='_blank' href='" + JsonData["pdf_path"] + "'>查看</a> | <a style='color: red;' href='#' onclick='RemoveTr(this, \"" + tbody_id + "\", \"" + JsonData["id"] + "\")'>删除</a>";
                td6.style.textAlign = "center";td6.style.border = "#cccccc solid 1px";td6.style.borderLeft = "none";td6.style.borderTop = "none";
                tr.appendChild(td1);tr.appendChild(td2);tr.appendChild(td3);tr.appendChild(td4);tr.appendChild(td5);tr.appendChild(td6);
                t_table.appendChild(tr);
            }
        }

        function RemoveTr(_this, tbody_id, wj_id) {
            var table = document.getElementById(tbody_id);
            var trNode = $(_this).parent().parent();
            trNode.remove();

            for (var i = 0; i < table.children.length; i++) {
                table.children[i].children[0].innerHTML = i + 1;
            }

            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/administrative/delete_attachments_view", true);
            xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
            xhr.send("id=" + String(wj_id));
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        console.log(JsonDate);
                        alert("删除成功！")
                    }
                }
            };
        }

        function submit_data() {
            var PartyGovOffice = {{ PartyGovOffice | safe }};

            var form = new FormData();
            var outgoingpersonnel = document.getElementById('outgoingpersonnel').innerText;         // 外出人员
            var duties = document.getElementById('post').innerText;                                 // 职务
            var start_time = document.getElementById('start_time').innerText;                       // 开始时间
            var end_time = document.getElementById('end_time').innerText;                           // 结束时间
            var destination = document.getElementById("destination").innerText;                     // 前往地点
            var reasons = document.getElementById("reasons").innerText;                             // 外出事由
            var department_obj = document.getElementsByClassName("department");
            var department_list = [];
            for (var i=0; i<department_obj.length; i++) {
                if (department_obj[i].checked) {
                    department_list.push(department_obj[i].value)
                }
            }
            if (!outgoingpersonnel) {
                alert("请选择外出人员！");
                return false
            }
            if (!duties) {
                alert("请填写职务！");
                return false
            }
            if (!start_time) {
                alert("请填写开始时间！");
                return false
            }
            if (!end_time) {
                alert("请填写结束时间！");
                return false
            }
            if (!destination) {
                alert("请填写前往地点！");
                return false
            }
            if (!reasons) {
                alert("请填写外出事由！");
                return false
            }

            if (PartyGovOffice) {
                if (department_list.length === 0) {
                    alert("请选择分管部门！");
                    return false
                }
            }
            form.append('uuid', uuid)
            form.append('outgoing_person', outgoingpersonnel)
            form.append('duties', duties)
            form.append('start_time', start_time)
            form.append('end_time', end_time)
            form.append('destination', destination)
            form.append('reasons', reasons)
            form.append('department_list', JSON.stringify(department_list))
            document.getElementById("loading").style.display = "inline-block";
            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/finance/OutgoingCadres.html", true);
            {#xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');#}
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        var JsonDate = JSON.parse(xhr.responseText);
                        if (JsonDate["code"] === 200) {
                            alert("创建成功");
                            window.location = "MiddleLevelCadres.html";
                            document.getElementById("loading").style.display = "none";
                        } else {
                            alert(JsonDate['message']);
                            document.getElementById("loading").style.display = "none";
                        }
                    }
                }
            };
        }

        function save_data() {
            var form = new FormData();
            var outgoingpersonnel = document.getElementById('outgoingpersonnel').innerText;         // 外出人员
            var duties = document.getElementById('post').innerText;                                 // 职务
            var start_time = document.getElementById('start_time').innerText;                       // 开始时间
            var end_time = document.getElementById('end_time').innerText;                           // 结束时间
            var destination = document.getElementById("destination").innerText;                     // 前往地点
            var reasons = document.getElementById("reasons").innerText;                             // 外出事由
            var department_obj = document.getElementsByClassName("department");
            var department_list = [];
            for (var i=0; i<department_obj.length; i++) {
                if (department_obj[i].checked) {
                    department_list.push(department_obj[i].value)
                }
            }
            form.append('uuid', uuid)
            form.append('outgoing_person', outgoingpersonnel)
            form.append('duties', duties)
            form.append('start_time', start_time)
            form.append('end_time', end_time)
            form.append('destination', destination)
            form.append('reasons', reasons)
            form.append('department_list', JSON.stringify(department_list))
            document.getElementById("loading").style.display = "inline-block";
            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/finance/middle_level_draft.html", true);
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        var JsonDate = JSON.parse(xhr.responseText);
                        if (JsonDate["code"] === 200) {
                            alert("保存成功！");
                            window.location = "MiddleLevelCadres.html";
                            document.getElementById("loading").style.display = "none";
                        } else {
                            alert(JsonDate['message']);
                            document.getElementById("loading").style.display = "none";
                        }
                    }
                }
            };
        }

        function SingleChoice(this_) {
            var department_list = document.getElementsByClassName('department');
            for (var i=0; i<department_list.length; i++) {
                department_list[i].checked = false;
            }
            this_.checked = true;
        }

        function IdentifyPersonnel() {
            var prople_list = [];
            var selected_personnel_list = document.getElementsByClassName('selected-personnel');
            for (var i=0; i<selected_personnel_list.length; i++) {
                prople_list.push(selected_personnel_list[i].innerText)
            }
            document.getElementById("outgoingpersonnel").innerText = prople_list.join();
            close_model()
        }

        function scrollConversationScreen() {
            $('#selected-div').scrollTop($('#selected-div')[0].scrollHeight);
        }
    </script>
{% endblock %}



